<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="statics/layui/css/layui.css">
    <style>
        body {
            padding: 30px 50px 30px 10px;
        }
    </style>
</head>
<body>
    <form class="layui-form" action="freemarker.action" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="username" required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" id="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" id="btn_save" lay-filter="demo1">提交</button>
                <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
            </div>
        </div>
    </form>
    <script type="text/javascript" src="statics/layui/layui.all.js"></script>
    <script>
        layui.use(['form', 'layer','laydate', 'jquery'], function (form, layer,laydate, $) {
            var index = parent.layer.getFrameIndex(window.name);
            $("#btn_save").click(function () {
                $name = $("#username").val();
                $pass = $("#password").val();
                $.post('freemarker.action', {name:$name,password:$pass}, function(str) {
                    if(str == "true"){
                        //location.href="toindex.action";
                        layer.msg('登录成功', {
                            icon: 1,//提示的样式
                            time: 1000, //2秒关闭（如果不配置，默认是3秒）//设置后不需要自己写定时关闭了，单位是毫秒
                            end:function(){
                                parent.location.href='toindex.action';
                            }
                        });
                    } else {
                        layer.msg('账号或密码错误！', {
                            icon: 0,//提示的样式
                            time: 1000, //2秒关闭（如果不配置，默认是3秒）//设置后不需要自己写定时关闭了，单位是毫秒
                        });
                    }
                });
            })
        });
    </script>
</body>
</html>